package hanshu;

import java.util.Arrays;
import java.util.Scanner;

enum Choice(fib,sort,search,getBirthDate,other)

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String strChoice;
        String[] strDigits;
        int[] digits=null;
        while(sc.hasNextLine()){
            strChoice=sc.hasNextLine();
            if(strChoice.equals("fib")){
                int n=Integer.parseInt(sc.NextLine());
                fib(n);
            }
            else if(strChoice.equals("sort")){
                String Line=sc.NextLine();
                strDigits=line.split(" ");
                digits=convertToIntDigits(strDigits);
                Arrays.sort(digits);
                System.out.println(Arrays.toString(digits));
            }
            else if(strChoice.equals("search")){
                Arrays.sort(digits);
                int digit=Integer.parseInt(sc.NextLine());
                int pos=Array.binarySearch(digits,digit);
                if(pos<0) System.out.println(-1);
                else System.out.println(pos);
            }
            else if(strChoice.equals("getBirthDate")){
                int m=Integer.parseInt(sc.NextLine());
                for(int i=0;i<m;i++){
                    String id=sc.NextLine();
                    System.out.println(getBirthDate(id));
                }
            }
            else System.out.println("exit");
        }
    }
}